package com.itfs.strategy;

import org.apache.commons.lang3.StringUtils;

public class StrategyTest {
    public static void main(String[] args) {
        //假如是普通会员
        finalTotal("Regular");
        //假如是年回环
        finalTotal("Year");
        //假如是永久会员
        finalTotal("Permanent");
    }
    /**
     * 结算，需要传入会员的类型
     * @param type
     */
    public static void finalTotal(String type){
        //声明一个消费者
        Consumer consumner = null;
        //对type进行判断
        if(StringUtils.equals(type,"Regular")){
            //普通会员
            consumner = new Consumer(new RegularMembers());
        }else if(StringUtils.equals(type,"Year")){
            //年会员
            consumner = new Consumer(new YearMembers());
        }else if(StringUtils.equals(type,"Permanent")){
            //永久会员
            consumner = new Consumer(new PermanentMembers());
        }else{
            throw new RuntimeException("不是会员");
        }
        //执行优惠
        consumner.execute();
    }
}